package org.example.controller;


import org.example.Inventory;
import org.example.Order;
import org.example.ResultMap;
import org.example.service.InventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope //@RefreshScope动态刷新配置实现原理
@RestController
@RequestMapping("inventory")
public class InventoryController {

    @Value("${config.name}")
    public String config;

    @RequestMapping("configTest")
    public String configTest() {
        return config;
    }

    @Autowired
    InventoryService inventoryService;

    @RequestMapping("reduceinventor")
    public ResultMap updateInventory(@RequestBody Order order) {
        return inventoryService.updateInventory(order);
    }
}
